﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Collections;

namespace WpfBrowserApplication
{
    /// <summary>
    /// Interaction logic for ListBoxPage.xaml
    /// </summary>
    public partial class ListViewCheckBoxPage : Page
    {
        public ListViewCheckBoxPage()
        {
            InitializeComponent();
        }

        private void Page_Loaded(object sender, RoutedEventArgs e)
        {
            List<string> datasource = GetDataSource();
            listViewData.ItemsSource = datasource;
            foreach (var item in listViewData.Items)
            {
                if (item.ToString() == "Test2")
                {
                    listViewData.SelectedItems.Add(item);
                }
            }
        }

        private List<string> GetDataSource()
        {
            List<string> list = new List<string>();
            for (int i = 0; i < 10; i++)
            {
                list.Add(string.Format("Test{0}", i));
            }
            return list;
        }

        private void btnSubmit_Click(object sender, RoutedEventArgs e)
        {
            foreach (var item in listViewData.SelectedItems)
            {
                MessageBox.Show(item.ToString());
            }
        }
    }
}
